# include <bits/stdc++.h>
using namespace std;

inline char getc() { 
    static char buf[1 << 9], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 9, stdin)), fs == ft) ? EOF : *fs++;
}

inline int gn() { 
    register int k = 0;
    register char c = getc();
    for(; !isdigit(c); c = getc()) ;
    for(; isdigit(c); c = getc()) k = k * 10 + c - '0';
    return k;
}

int n, p, x, y;

int main() { 
# ifndef LOCAL
    freopen("hztp.in", "r", stdin);
    freopen("hztp.out", "w", stdout);
# endif
    n = gn();
    for(int i = 1; i <= n; i++) { 
        p = gn();
        if(!y) { 
            x = p; 
            y++;
        } else if(p == x) { 
            y++;
        } else { 
            y--;
        }
    }
    printf("%d\n", x);
    return 0;
}
